package me.zhengjie.config;

import com.alibaba.druid.support.http.WebStatFilter;
import com.alibaba.druid.support.http.stat.WebAppStat;
import com.alibaba.druid.support.http.stat.WebSessionStat;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.security.core.context.SecurityContextHolder;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * <b>请输入名称</b>
 * <pre>
 * 描述<br/>
 * 作用：；<br/>
 * 限制：；<br/>
 * </pre>
 *
 * @author 胡安稳
 * @date 2024/12/5 15:08
 */
public class CustomWebStatFilter extends WebStatFilter {

//    @Override
//    public WebSessionStat getSessionStat(HttpServletRequest request){
//        return super.getSessionStat(request);
//    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{
        super.doFilter(request, response, chain);
    }

    @Override
    public String getSessionId(HttpServletRequest httpRequest) {
        return SecurityUtils.getCurrentUserId().toString();

    }

    @Override
    public String getPrincipal(HttpServletRequest httpRequest) {
        return SecurityUtils.getCurrentUsername();
    }

    @Override
    public boolean isExclusion(String requestURI){
        return !requestURI.startsWith("/api");
    }

}

